package org.qf.web;

import org.qf.pojo.Goods;
import org.qf.service.impl.SmbmsGoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author zzzyyystart
 * @create 2022-05-11-19:38
 */
@WebServlet(value = "/goodsServlet")
public class SmbmsGoodsServlet extends HttpServlet {
    SmbmsGoodsServiceImpl goodsService= new SmbmsGoodsServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      String classifyName = req.getParameter("classify");
        List<Goods> goods = goodsService.showGoods(classifyName);
        req.getSession().setAttribute("classifyName",classifyName);
        req.getSession().setAttribute("goods", goods);
        req.getRequestDispatcher("goodsEdit.jsp").forward(req,resp);

    }
}
